<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    //随机生成一个0-100的数，判断是奇数还是偶数
    var sum = Math.round(Math.random() * 100);
    if (sum % 2 == 0) {
        console.log(sum + "为偶数");
    } else if (sum % 2 != 0) {
        console.log(sum + "为奇数");
    }

    //计算y的值并输出
    var y, x = Math.ceil(Math.random() * 200 - 100);
    console.log("x=" + x);
    if (x < 1) {
        y = x;
    } else if (x >= 1 && x < 10) {
        y = 2 * x + 1;
    } else {
        y = 5 * x - 17;
    }
    console.log("y=" + y);

    //随机一个1000-9999的数判断该数是否是闰年
    var num = Math.round(1000 + Math.random() * 8999);
    if (num % 4 == 0 && num % 100 != 0 || num % 400 == 0) {
        console.log(num + "年为闰年");
    } else {
        console.log(num + "年为平年");
    }

</script>

</html>